/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controllers;

/**
 *
 * @author emovabilisim
 */

import DAO.EventDAO;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.EventBean;
import model.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/subscribeevent.htm")
public class SubscribeEventController {
    
    @RequestMapping(method = RequestMethod.GET)
    public String process(Map model,
    @RequestParam(value = "eventId", required = true) int eventId,
    HttpServletRequest request,HttpServletResponse response){
        
        HttpSession session = request.getSession(true);
        UserBean currentUser = (UserBean)(session.getAttribute("currentSessionUser"));
        
        EventDAO eventDAO = new EventDAO();
        eventDAO.subscribeEvent(eventId,currentUser.getUserId());
        
        List<EventBean> eventBeans = eventDAO.getIsolatedPersonEvents(currentUser);
        model.put("events",eventBeans);
        
        return "isolatedpersonevents";
    }
}
